{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Examples require an initialized GsSession and relevant entitlements. External clients need to substitute thier own client id and client secret below. Please refer to [Authentication](https://developer.gs.com/p/docs/institutional/platform/authentication/) for details."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from gs_quant.session import GsSession\n",
    "GsSession.use(client_id=None, client_secret=None, scopes=('read_product_data',))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "from gs_quant.data import Dataset"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "# get the dataset\n",
    "dataset = Dataset('EDRVOL_PERCENT_STANDARD')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Dataset Coverage\n",
    "Dataset coverage is a list of the symbol dimensions in a dataset. This allows users to quickly see what is available in a dataset.\n",
    "Coverage can by fetched via API as below or in the [dataset product page](https://marquee.gs.com/s/developer/datasets/EDRVOL_PERCENT_STANDARD/coverage)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(25, 4)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# get the coverage\n",
    "coverage = dataset.get_coverage(include_history=True)\n",
    "\n",
    "# show the number of records and columns\n",
    "coverage.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['bbid', 'assetId', 'name', 'historyStartDate'], dtype='object')"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# show the columns names\n",
    "coverage.keys()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>bbid</th>\n",
       "      <th>assetId</th>\n",
       "      <th>name</th>\n",
       "      <th>historyStartDate</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>AEX</td>\n",
       "      <td>MA4B66MW5E27U8NN8LS</td>\n",
       "      <td>AEX Index</td>\n",
       "      <td>2018-06-03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>IBOV</td>\n",
       "      <td>MA4B66MW5E27U8NN8N6</td>\n",
       "      <td>Brazil Ibovespa Index</td>\n",
       "      <td>2018-06-03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>INDU</td>\n",
       "      <td>MA4B66MW5E27U8NN8SP</td>\n",
       "      <td>Dow Jones Industrial Average</td>\n",
       "      <td>2018-06-03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>CAC</td>\n",
       "      <td>MA4B66MW5E27U8NN922</td>\n",
       "      <td>CAC 40 Index</td>\n",
       "      <td>2018-06-03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>UKX</td>\n",
       "      <td>MA4B66MW5E27U8NN95P</td>\n",
       "      <td>FTSE 100 Index</td>\n",
       "      <td>2018-06-03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>DAX</td>\n",
       "      <td>MA4B66MW5E27U8NPZQY</td>\n",
       "      <td>DAX Index</td>\n",
       "      <td>2018-06-03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>HSCEI</td>\n",
       "      <td>MA4B66MW5E27U8P3294</td>\n",
       "      <td>Hang Seng China Ent Index</td>\n",
       "      <td>2018-06-03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>HSI</td>\n",
       "      <td>MA4B66MW5E27U8P3295</td>\n",
       "      <td>Hang Seng Index</td>\n",
       "      <td>2018-06-03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>KOSPI2</td>\n",
       "      <td>MA4B66MW5E27U8P32DM</td>\n",
       "      <td>KOSPI 200 Index</td>\n",
       "      <td>2018-06-03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>MXEA</td>\n",
       "      <td>MA4B66MW5E27U8P32GB</td>\n",
       "      <td>MSCI EAFE</td>\n",
       "      <td>2018-06-03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>MXEF</td>\n",
       "      <td>MA4B66MW5E27U8P32KK</td>\n",
       "      <td>MSCI Emerging Markets Index</td>\n",
       "      <td>2018-06-03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>MEXBOL</td>\n",
       "      <td>MA4B66MW5E27U8P32LE</td>\n",
       "      <td>S&amp;P/bmv Ipc</td>\n",
       "      <td>2018-06-03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>NKY</td>\n",
       "      <td>MA4B66MW5E27U8P32LH</td>\n",
       "      <td>Nikkei 225</td>\n",
       "      <td>2018-06-03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>NDX</td>\n",
       "      <td>MA4B66MW5E27U8P32LQ</td>\n",
       "      <td>Nasdaq 100 Stock Index</td>\n",
       "      <td>2018-06-03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>RTY</td>\n",
       "      <td>MA4B66MW5E27U8P32PC</td>\n",
       "      <td>Russell 2000 Index</td>\n",
       "      <td>2018-06-03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>SPTSX60</td>\n",
       "      <td>MA4B66MW5E27U8P32S9</td>\n",
       "      <td>S&amp;P/TSX 60 Index</td>\n",
       "      <td>2018-06-03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>SPX</td>\n",
       "      <td>MA4B66MW5E27U8P32SB</td>\n",
       "      <td>S&amp;P 500 Index</td>\n",
       "      <td>2018-06-03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>SMI</td>\n",
       "      <td>MA4B66MW5E27U8P32SR</td>\n",
       "      <td>Swiss Market Index</td>\n",
       "      <td>2018-06-03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>SX5E</td>\n",
       "      <td>MA4B66MW5E27U8P32SY</td>\n",
       "      <td>Euro Stoxx 50 Price Return</td>\n",
       "      <td>2018-06-03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>TPX</td>\n",
       "      <td>MA4B66MW5E27U8P32XG</td>\n",
       "      <td>TOPIX Index (Tokyo)</td>\n",
       "      <td>2018-06-03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>EEM UP</td>\n",
       "      <td>MA4B66MW5E27UAEP4R5</td>\n",
       "      <td>iShares MSCI Emerging Markets</td>\n",
       "      <td>2018-06-03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>EFA UP</td>\n",
       "      <td>MA4B66MW5E27UAEP4RT</td>\n",
       "      <td>iShares MSCI EAFE ETF</td>\n",
       "      <td>2018-06-03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>GLD UP</td>\n",
       "      <td>MA4B66MW5E27UAGYYRR</td>\n",
       "      <td>SPDR Gold Shares</td>\n",
       "      <td>2018-06-03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>XLF UP</td>\n",
       "      <td>MA4B66MW5E27UANZH2R</td>\n",
       "      <td>Financial Select Sector SPDR</td>\n",
       "      <td>2018-06-03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>XLK UP</td>\n",
       "      <td>MA4B66MW5E27UANZH2T</td>\n",
       "      <td>Technology Select Sect SPDR</td>\n",
       "      <td>2018-06-03</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       bbid              assetId                           name  \\\n",
       "0       AEX  MA4B66MW5E27U8NN8LS                      AEX Index   \n",
       "1      IBOV  MA4B66MW5E27U8NN8N6          Brazil Ibovespa Index   \n",
       "2      INDU  MA4B66MW5E27U8NN8SP   Dow Jones Industrial Average   \n",
       "3       CAC  MA4B66MW5E27U8NN922                   CAC 40 Index   \n",
       "4       UKX  MA4B66MW5E27U8NN95P                 FTSE 100 Index   \n",
       "5       DAX  MA4B66MW5E27U8NPZQY                      DAX Index   \n",
       "6     HSCEI  MA4B66MW5E27U8P3294      Hang Seng China Ent Index   \n",
       "7       HSI  MA4B66MW5E27U8P3295                Hang Seng Index   \n",
       "8    KOSPI2  MA4B66MW5E27U8P32DM                KOSPI 200 Index   \n",
       "9      MXEA  MA4B66MW5E27U8P32GB                      MSCI EAFE   \n",
       "10     MXEF  MA4B66MW5E27U8P32KK    MSCI Emerging Markets Index   \n",
       "11   MEXBOL  MA4B66MW5E27U8P32LE                    S&P/bmv Ipc   \n",
       "12      NKY  MA4B66MW5E27U8P32LH                     Nikkei 225   \n",
       "13      NDX  MA4B66MW5E27U8P32LQ         Nasdaq 100 Stock Index   \n",
       "14      RTY  MA4B66MW5E27U8P32PC             Russell 2000 Index   \n",
       "15  SPTSX60  MA4B66MW5E27U8P32S9               S&P/TSX 60 Index   \n",
       "16      SPX  MA4B66MW5E27U8P32SB                  S&P 500 Index   \n",
       "17      SMI  MA4B66MW5E27U8P32SR             Swiss Market Index   \n",
       "18     SX5E  MA4B66MW5E27U8P32SY     Euro Stoxx 50 Price Return   \n",
       "19      TPX  MA4B66MW5E27U8P32XG            TOPIX Index (Tokyo)   \n",
       "20   EEM UP  MA4B66MW5E27UAEP4R5  iShares MSCI Emerging Markets   \n",
       "21   EFA UP  MA4B66MW5E27UAEP4RT          iShares MSCI EAFE ETF   \n",
       "22   GLD UP  MA4B66MW5E27UAGYYRR               SPDR Gold Shares   \n",
       "23   XLF UP  MA4B66MW5E27UANZH2R   Financial Select Sector SPDR   \n",
       "24   XLK UP  MA4B66MW5E27UANZH2T    Technology Select Sect SPDR   \n",
       "\n",
       "   historyStartDate  \n",
       "0        2018-06-03  \n",
       "1        2018-06-03  \n",
       "2        2018-06-03  \n",
       "3        2018-06-03  \n",
       "4        2018-06-03  \n",
       "5        2018-06-03  \n",
       "6        2018-06-03  \n",
       "7        2018-06-03  \n",
       "8        2018-06-03  \n",
       "9        2018-06-03  \n",
       "10       2018-06-03  \n",
       "11       2018-06-03  \n",
       "12       2018-06-03  \n",
       "13       2018-06-03  \n",
       "14       2018-06-03  \n",
       "15       2018-06-03  \n",
       "16       2018-06-03  \n",
       "17       2018-06-03  \n",
       "18       2018-06-03  \n",
       "19       2018-06-03  \n",
       "20       2018-06-03  \n",
       "21       2018-06-03  \n",
       "22       2018-06-03  \n",
       "23       2018-06-03  \n",
       "24       2018-06-03  "
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# show the coverage\n",
    "coverage"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>bbid</th>\n",
       "      <th>assetId</th>\n",
       "      <th>name</th>\n",
       "      <th>historyStartDate</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>SPX</td>\n",
       "      <td>MA4B66MW5E27U8P32SB</td>\n",
       "      <td>S&amp;P 500 Index</td>\n",
       "      <td>2018-06-03</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   bbid              assetId           name historyStartDate\n",
       "16  SPX  MA4B66MW5E27U8P32SB  S&P 500 Index       2018-06-03"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# find specific asset\n",
    "coverage[coverage['bbid'] == 'SPX']"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  },
  "pycharm": {
   "stem_cell": {
    "cell_type": "raw",
    "source": [],
    "metadata": {
     "collapsed": false
    }
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}